﻿using Furion;
using Furion.DynamicApiController;
using GWB.Application.Common;
using GWB.Application.System.RoleManage.Dtos;
using GWB.Application.System.RoleManage.RoleService;
using GWB.Core;
using GWB.Core.Enum;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GWB.Application.System.RoleManage
{

    /// <summary>
    /// 角色管理
    /// </summary>
    [ApiDescriptionSettings("系统管理", Tag = "角色管理", SplitCamelCase = false)]
    public class RoleAppService: IDynamicApiController
    {
        /// <summary>
        ///新增
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        [Authorization(Name = "新增角色", Code = AuthCode.Add)]
        public async Task<Result<RoleOutDto>> Add(RoleCreateOrUpdateInputDto inputDto)
        {
            return await App.GetService<IRoleService>().Add(inputDto);
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        [Authorization(Name = "修改角色", Code = AuthCode.Update)]
        public async Task<bool> Update(RoleCreateOrUpdateInputDto inputDto)
        {
            return await App.GetService<IRoleService>().Update(inputDto);
        }



        /// <summary>
        /// 删除菜单
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [Authorization(Name = "修改角色", Code = AuthCode.Delete)]
        public async Task<bool> Delete(List<long> ids) 
        {
            return await App.GetService<IRoleService>().Delete(ids);

        }


        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        [Authorization(Name = "查询角色", Code = AuthCode.Page)]
        public async Task<PageResult<RoleOutDto>> Page(RolePageInputDto inputDto)
        {
            return await App.GetService<IRoleService>().Page(inputDto);
        }

        /// <summary>
        /// 编辑角色菜单
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        [Authorization(Name = "编辑角色菜单", Code = AuthCode.None)]
        public async Task<bool> EditRoleMenu(RoleMenuEditInputDto inputDto)
        {
            return await App.GetService<IRoleService>().EditRoleMenu(inputDto);
        }

        /// <summary>
        /// 获取角色菜单
        /// </summary>
        /// <param name="roelId"></param>
        /// <returns></returns>
        [Authorization(Name = "获取角色菜单", Code = AuthCode.None)]
        public async Task<List<RoletMenuOutDto>> GetRoleMenus(long roelId)
        {
            return await App.GetService<IRoleService>().GetRoleMenus(roelId);
        }

    }
}
